  class TreeNode {
    int val;
      TreeNode left;
      TreeNode right;
      TreeNode() {}
      TreeNode(int val) { this.val = val; }
      TreeNode(int val, TreeNode left, TreeNode right) {
          this.val = val;
          this.left = left;
          this.right = right;
      }
  }

public class demo1 {
    public TreeNode pruneTree(TreeNode root) {
        if(root==null) return null;
        //就是在root基础上进行修改不需要重新new节点
        //  TreeNode Lroot= pruneTree(root.left);
        //  TreeNode Rroot=pruneTree(root.right);
        root.left=pruneTree(root.left);
        root.right=pruneTree(root.right);
        if(root.left==null&&root.right==null){
            if(root.val==0)root=null;
        }
        return root;
    }
}
